package pl.edu.pw.elka.tinyrepo.gate.descriptor;

import java.math.BigDecimal;

import pl.edu.pw.elka.tinyrepo.dataserver.server.DataServerFacade;

public class DataServerDescriptor implements Comparable<DataServerDescriptor> {
   private String hostName;
   private DataServerFacade dsStub;
   /** Zajetosc dysku. */
   private Long diskUsage = 0L; // FIXME moze okazac sie za mala precyzja
   
   public DataServerDescriptor(String hostName, DataServerFacade dsStub) {
      super();
      this.hostName = hostName;
      this.dsStub = dsStub;
   }
   
   /**
    * @return the hostName
    */
   public String getHostName() {
      return hostName;
   }

   /**
    * @param hostName the hostName to set
    */
   public synchronized void setHostName(String hostName) {
      this.hostName = hostName;
   }

   /**
    * @return the dsStub
    */
   public synchronized DataServerFacade getDsStub() { // rowniez synchronized bo stub moze byc modyfikowany
      return dsStub;
   }

   /**
    * @param dsStub the dsStub to set
    */
   public synchronized void setDsStub(DataServerFacade dsStub) {
      this.dsStub = dsStub;
   }

   /**
    * @return the diskUsage
    */
   public Long getDiskUsage() {
      return diskUsage;
   }

   /**
    * @param diskUsage the diskUsage to set
    */
   public synchronized void setDiskUsage(Long diskUsage) {
      this.diskUsage = diskUsage;
   }

   @Override
   public String toString() {
      return hostName+"="+diskUsage;
   } 
  
   @Override
   public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((hostName == null) ? 0 : hostName.hashCode());
      return result;
   }

   @Override
   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      DataServerDescriptor other = (DataServerDescriptor) obj;
      if (hostName == null) {
         if (other.hostName != null)
            return false;
      } else if (!hostName.equals(other.hostName))
         return false;
      return true;
   }

   @Override
   public int compareTo(DataServerDescriptor arg0) {
      return diskUsage.compareTo(arg0.diskUsage); // w ten sposob mamy porownywanie wg min.
   }

  
   
}
